﻿namespace IS.Projecto.Modelo
{
    public class Docente : Entidade
    {
        public string Nome { get; set; }

        public bool Equals(Docente other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return (Id != -1 && other.Id != -1 && Id == other.Id) || ((Id == -1 || other.Id == -1) && Equals(other.Nome, Nome));
        }

        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>. 
        ///                 </param><exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.
        ///                 </exception><filterpriority>2</filterpriority>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Docente)) return false;
            return Equals((Docente) obj);
        }

        /// <summary>
        /// Serves as a hash function for a particular type. 
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public override int GetHashCode()
        {
            int hashcode = base.GetHashCode();
            return hashcode * 396 + (Nome != null ? Nome.GetHashCode() : 0);
        }

        public static bool operator ==(Docente left, Docente right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(Docente left, Docente right)
        {
            return !Equals(left, right);
        }
    }
}